<?php
/**
 * Insert an rail_object from clipboard. If is set $_GET['obj'] insert into this object, otherwise into the current object.
 *
 * PHP versions 5
 *
 * Copyright (C)
 * This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation. Either version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. Without even the implied warranty
 * of ERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program. Ff not, write to the Free Software
 * Fundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 *
 * Copyright (C) 2006-2007
 *
 * @author Bastian Schröder <bs@chemanet.de>
 * @version 2008-04-17
 * @package railbrowser
 */

function ajax_call( $ajaxBridge ) {
	global $rail, $object;
	$object = isset($_GET['obj']) ? rail_factory::get_object( $rail, $_GET['obj'] ) : $object;

	// return if clipboard is empty
	if( !isset($_SESSION['clipboard']) ) return;

	// connect to clipboards mysql and rail
	$rail_connector = new rail_connector(
		$_SESSION['clipboard']['mysql_db'],
		$_SESSION['clipboard']['mysql_user'],
		$_SESSION['clipboard']['mysql_passwd'],
		$_SESSION['clipboard']['mysql_host']
	);
	$rail_connector->login( $_SESSION['clipboard']['rail_user'], $_SESSION['clipboard']['rail_passwd'] );
	$src_object = rail_factory::get_object( $rail_connector, $_SESSION['clipboard']['object'] );

	// copy or cut(move)
	if( !$_SESSION['clipboard']['copy_and_cut'] )
		$src_object->copy( $object, true );
	else
		$src_object->move( $object );
}

?>